/*
Kiwi Editor is a framework for building WYSIWYG web editors.
Copyright (C) 2011  Roosevelt de Lima Sardinha

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

Contact the author at roosevelt1@gmail.com (Roosevelt) 
*/
function keyboard()
{
	this.EOM = null
	
	var thisObject  = this;

	this.enabled = true;

	this.keyManager = function(e)
	{
		var code;
		if (!e) var e = window.event;
		if (e.keyCode)
		{
			code = e.keyCode;
		}
		else if (e.which)
		{
		 	code = e.which;
		}
		
		switch (code){
			case 46: // Delete key pressed
				this.EOM.removeSelectedEOs();
				break;
			case 67: // C key pressed
				if (e.ctrlKey) //Ctrl + C pressed
				{	
					this.EOM.cleanMemo();
					this.EOM.copySelectedEOs();
				}
				break;
			case 86: // V key pressed
				if (e.ctrlKey) // Ctrl + V pressed
				{
					var memo = this.EOM.retrieveMemo();
					for(var i=0; i < memo.length; i++)
					{	
						this.EOM.editionArea.appendObject(memo[i]);
					}
					this.EOM.cleanMemo();
				}
				break;
			default:
				break;
		}
	}

	document.onkeydown = function(e) {
		if (thisObject.enabled == true)
		{
			thisObject.keyManager(e);
		}
	}
}

